package gui.mainWindow.finals;

import gui.mainWindow.MainWindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.LayoutStyle;
import javax.swing.SpinnerListModel;
import javax.swing.WindowConstants;

import tournamentTree.TournamentNode;

import com.mxgraph.model.mxCell;

import core.Constants;
import core.GuiComponentLabels;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class FinalsEntryWindow extends javax.swing.JFrame {
	private JPanel leftPlayerPanel;
	private JLabel leftPlayerName;
	private JLabel leftPlayerScoreLabel;
	private JCheckBox leftPlayerHeadsUpCheckBox;
	private JSpinner rightPlayerScoreSpinner;
	private JLabel rightPlayerScoreLabel;
	private JLabel rightPlayerClub;
	private JButton cancelButton;
	private JButton okButton;
	private JCheckBox rightPlayerHeadsUpCheckBox;
	private JLabel rightPlayerSurName;
	private JLabel rightPlayerName;
	private JPanel rightPlayerPanel;
	private JLabel leftPlayerClub;
	private JSpinner leftPlayerScoreSpinner;
	private JLabel leftPlayerSurName;
	private final FinalsEntryWindowController controller;
	private final MainWindow window;
	private TournamentNode leftPlayerNode;
	private TournamentNode rightPlayerNode;

	public FinalsEntryWindow(MainWindow window, mxCell selectedCell) {
		super();
		this.window = window;
		this.setUndecorated(true);
		this.initGUI();
		this.controller = new FinalsEntryWindowController(this, selectedCell);
	}

	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout(this.getContentPane());
			this.getContentPane().setLayout(thisLayout);
			this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setAlwaysOnTop(true);
			{
				this.leftPlayerPanel = new JPanel();
				GroupLayout leftPlayerPanelLayout = new GroupLayout(this.leftPlayerPanel);
				this.leftPlayerPanel.setBorder(BorderFactory.createTitledBorder(GuiComponentLabels.LEFT));
				this.leftPlayerPanel.setLayout(leftPlayerPanelLayout);
				{
					this.leftPlayerName = new JLabel();
					this.leftPlayerName.setText("lName");
				}
				{
					this.leftPlayerSurName = new JLabel();
					this.leftPlayerSurName.setText("lSurName");
				}
				{
					this.leftPlayerScoreLabel = new JLabel();
					this.leftPlayerScoreLabel.setText(GuiComponentLabels.SCORE);
				}
				{
					SpinnerListModel leftPlayerScoreSpinnerModel = new SpinnerListModel(Constants.VALIDSCORES);
					this.leftPlayerScoreSpinner = new JSpinner();
					this.leftPlayerScoreSpinner.setModel(leftPlayerScoreSpinnerModel);
				}
				{
					this.leftPlayerHeadsUpCheckBox = new JCheckBox();
					this.leftPlayerHeadsUpCheckBox.setText(GuiComponentLabels.HEADS_UP);
					this.leftPlayerHeadsUpCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
					this.leftPlayerHeadsUpCheckBox.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							if (FinalsEntryWindow.this.leftPlayerHeadsUpCheckBox.isSelected()) {
								FinalsEntryWindow.this.rightPlayerHeadsUpCheckBox.setSelected(false);
							}
						}
					});
				}
				{
					this.leftPlayerClub = new JLabel();
					this.leftPlayerClub.setText("lClub");
				}
				leftPlayerPanelLayout.setHorizontalGroup(leftPlayerPanelLayout.createSequentialGroup().addContainerGap().addGroup(
						leftPlayerPanelLayout.createParallelGroup().addGroup(
								GroupLayout.Alignment.LEADING,
								leftPlayerPanelLayout.createSequentialGroup().addComponent(this.leftPlayerScoreLabel, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE).addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.leftPlayerScoreSpinner, 0, 129, Short.MAX_VALUE)).addGroup(
								leftPlayerPanelLayout.createSequentialGroup().addComponent(this.leftPlayerName, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE).addGap(0, 0,
										Short.MAX_VALUE)).addGroup(
								leftPlayerPanelLayout.createSequentialGroup().addComponent(this.leftPlayerSurName, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE).addGap(0, 0,
										Short.MAX_VALUE)).addComponent(this.leftPlayerClub, GroupLayout.Alignment.LEADING, 0, 205, Short.MAX_VALUE).addComponent(this.leftPlayerHeadsUpCheckBox,
								GroupLayout.Alignment.LEADING, 0, 205, Short.MAX_VALUE)).addContainerGap());
				leftPlayerPanelLayout.setVerticalGroup(leftPlayerPanelLayout.createSequentialGroup().addComponent(this.leftPlayerName, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.leftPlayerSurName, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.leftPlayerClub, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
						leftPlayerPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.leftPlayerScoreSpinner, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
								22, GroupLayout.PREFERRED_SIZE).addComponent(this.leftPlayerScoreLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.leftPlayerHeadsUpCheckBox, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
			}
			{
				this.rightPlayerPanel = new JPanel();
				GroupLayout jPanel1Layout = new GroupLayout(this.rightPlayerPanel);
				this.rightPlayerPanel.setBorder(BorderFactory.createTitledBorder(GuiComponentLabels.RIGHT));
				this.rightPlayerPanel.setLayout(jPanel1Layout);
				{
					SpinnerListModel rightPlayerScoreSpinnerModel = new SpinnerListModel(Constants.VALIDSCORES);
					this.rightPlayerScoreSpinner = new JSpinner();
					this.rightPlayerScoreSpinner.setModel(rightPlayerScoreSpinnerModel);
				}
				{
					this.rightPlayerScoreLabel = new JLabel();
					this.rightPlayerScoreLabel.setText(GuiComponentLabels.SCORE);
				}
				{
					this.rightPlayerName = new JLabel();
					this.rightPlayerName.setText("rName");
				}
				{
					this.rightPlayerSurName = new JLabel();
					this.rightPlayerSurName.setText("rSurName");
				}
				{
					this.rightPlayerClub = new JLabel();
					this.rightPlayerClub.setText("rClub");
				}
				{
					this.rightPlayerHeadsUpCheckBox = new JCheckBox();
					this.rightPlayerHeadsUpCheckBox.setText(GuiComponentLabels.HEADS_UP);
					this.rightPlayerHeadsUpCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
					this.rightPlayerHeadsUpCheckBox.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							if (FinalsEntryWindow.this.rightPlayerHeadsUpCheckBox.isSelected()) {
								FinalsEntryWindow.this.leftPlayerHeadsUpCheckBox.setSelected(false);
							}

						}
					});
				}
				jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(
						jPanel1Layout.createParallelGroup().addGroup(
								GroupLayout.Alignment.LEADING,
								jPanel1Layout.createSequentialGroup().addComponent(this.rightPlayerScoreLabel, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE).addPreferredGap(
										LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.rightPlayerScoreSpinner, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE).addGap(0, 0,
										Short.MAX_VALUE)).addGroup(
								jPanel1Layout.createSequentialGroup().addComponent(this.rightPlayerName, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE).addGap(0, 0, Short.MAX_VALUE))
								.addGroup(
										jPanel1Layout.createSequentialGroup().addComponent(this.rightPlayerSurName, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE).addGap(0, 0,
												Short.MAX_VALUE)).addComponent(this.rightPlayerClub, GroupLayout.Alignment.LEADING, 0, 205, Short.MAX_VALUE).addComponent(
										this.rightPlayerHeadsUpCheckBox, GroupLayout.Alignment.LEADING, 0, 205, Short.MAX_VALUE)).addContainerGap());
				jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addComponent(this.rightPlayerName, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.rightPlayerSurName, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.rightPlayerClub,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(
						jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.rightPlayerScoreSpinner, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22,
								GroupLayout.PREFERRED_SIZE).addComponent(this.rightPlayerScoreLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.rightPlayerHeadsUpCheckBox, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
			}
			{
				this.okButton = new JButton();
				this.okButton.setText(GuiComponentLabels.OK_BUTTON);
				this.okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						FinalsEntryWindow.this.controller.setWinner();
						FinalsEntryWindow.this.dispose();
					}
				});
			}
			{
				this.cancelButton = new JButton();
				this.cancelButton.setText(GuiComponentLabels.CANCEL_BUTTON);
				this.cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						FinalsEntryWindow.this.dispose();
					}
				});
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap().addGroup(
					thisLayout.createParallelGroup().addComponent(this.leftPlayerPanel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE).addComponent(
							this.rightPlayerPanel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE)).addPreferredGap(
					LayoutStyle.ComponentPlacement.UNRELATED).addGroup(
					thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.okButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
							GroupLayout.PREFERRED_SIZE).addComponent(this.cancelButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
							GroupLayout.PREFERRED_SIZE)));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap().addComponent(this.leftPlayerPanel, GroupLayout.PREFERRED_SIZE, 239, GroupLayout.PREFERRED_SIZE).addGap(
					12).addGroup(
					thisLayout.createParallelGroup().addGroup(
							GroupLayout.Alignment.LEADING,
							thisLayout.createSequentialGroup().addComponent(this.cancelButton, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE).addPreferredGap(
									LayoutStyle.ComponentPlacement.UNRELATED).addComponent(this.okButton, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)).addGroup(
							thisLayout.createSequentialGroup().addComponent(this.rightPlayerPanel, GroupLayout.PREFERRED_SIZE, 239, GroupLayout.PREFERRED_SIZE))).addContainerGap(36, Short.MAX_VALUE));
			this.pack();
			this.setSize(544, 233);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

	public MainWindow getMainWindow() {
		return this.window;
	}

	public JLabel getLeftPlayerName() {
		return this.leftPlayerName;
	}

	public JCheckBox getLeftPlayerHeadsUpCheckBox() {
		return this.leftPlayerHeadsUpCheckBox;
	}

	public JSpinner getRightPlayerScoreSpinner() {
		return this.rightPlayerScoreSpinner;
	}

	public JLabel getRightPlayerClub() {
		return this.rightPlayerClub;
	}

	public JCheckBox getRightPlayerHeadsUpCheckBox() {
		return this.rightPlayerHeadsUpCheckBox;
	}

	public JLabel getRightPlayerSurName() {
		return this.rightPlayerSurName;
	}

	public JLabel getRightPlayerName() {
		return this.rightPlayerName;
	}

	public JLabel getLeftPlayerClub() {
		return this.leftPlayerClub;
	}

	public JSpinner getLeftPlayerScoreSpinner() {
		return this.leftPlayerScoreSpinner;
	}

	public JLabel getLeftPlayerSurName() {
		return this.leftPlayerSurName;
	}

	public MainWindow getWindow() {
		return this.window;
	}

	public FinalsEntryWindowController getController() {
		return this.controller;
	}

	public TournamentNode getleftPlayerNode() {
		return this.leftPlayerNode;
	}

	public void setleftPlayerNode(TournamentNode leftPlayerNode) {
		this.leftPlayerNode = leftPlayerNode;
	}

	public TournamentNode getrightPlayerNode() {
		return this.rightPlayerNode;
	}

	public void setRightPlayerNode(TournamentNode rightPlayerNode) {
		this.rightPlayerNode = rightPlayerNode;
	}

}
